window.onload = function () 
{
	//登录状态
	var username = localStorage.getItem("username");
	if(username!=null)
	document.getElementById("login-link").innerHTML =  username ;
	
	//访问计数
	if (localStorage.pagecount)
		{
		localStorage.pagecount=Number(localStorage.pagecount) +1;
		}
	else
		{
		localStorage.pagecount=1;
		}
		document.getElementById("displayvisit").innerHTML = "<span>"  + localStorage.pagecount + " visits" + "</span>";
    
	//时间
	var oDt = new Date();
    var sWd = "";
    var iWeekDay = oDt.getDay();
    switch (iWeekDay) {
        case 0:
            sWd = "Sun.";
            break;
        case 1:
            sWd = "Mon.";
            break;
        case 2:
            sWd = "Tue.";
            break;
        case 3:
            sWd = "Wed.";
            break;
        case 4:
            sWd = "Thu.";
            break;
        case 5:
            sWd = "Fri.";
            break;
        case 6:
            sWd = "Sat.";
            break;
    }
    var iMonth = parseInt(oDt.getMonth()) + 1;
    document.getElementById("displaydate").innerHTML = "<span>" + iMonth + " / " + oDt.getDate() + " / " + oDt.getFullYear() + " " + sWd + "</span>";
	var iTimerid = window.setInterval("showtime()", 1000);

	//广告
    document.getElementById("checkpoint-1").onmouseover = function () 
	{
		clearAllCheckpoint();
		document.getElementById("checkpoint-1").style.backgroundColor="#ffffff";
		
		document.getElementById("home-show-media-address").href="https://www.ubisoft.com/en-us/game/rainbow-six/siege/events/grand-larceny";
		document.getElementById("home-show-info-address").href="https://www.ubisoft.com/en-us/game/rainbow-six/siege/events/grand-larceny";
		
        document.getElementById("home-show-media-box-img").alt="The Grand Larceny";	
		document.getElementById("home-show-media-box-img").src = "./img/r6s-home-header-grandLarceny.jpg";
		
		document.getElementById("home-show-media-box-video").alt="The Grand Larceny";
		document.getElementById("home-show-media-box-video").poster="./img/r6s-home-header-grandLarceny.jpg";	
		document.getElementById("home-show-media-box-video").src = "./img/r6s-home-header-grandLarceny.mp4";
		
		document.getElementById("home-show-info-1").innerHTML="The Grand Larceny";
		document.getElementById("home-show-info-2").innerHTML="激战风云";
    }
    document.getElementById("checkpoint-2").onmouseover = function () 
	{
		clearAllCheckpoint();
		document.getElementById("checkpoint-2").style.backgroundColor="#ffffff";
		
		document.getElementById("home-show-media-address").href="https://www.ubisoft.com/en-us/game/rainbow-six/siege/news-updates/3pIuqrgUo9GcOHKKc6Tv9d/r6-vintage-fashion-fanart-contest";
		document.getElementById("home-show-info-address").href="https://www.ubisoft.com/en-us/game/rainbow-six/siege/news-updates/3pIuqrgUo9GcOHKKc6Tv9d/r6-vintage-fashion-fanart-contest";
		
		document.getElementById("home-show-media-box-img").alt="The Grand Larceny";
		document.getElementById("home-show-media-box-img").src = "./img/r6s-event-header-grandLarceny.jpg";
		
		document.getElementById("home-show-media-box-video").alt="The Grand Larceny";
		document.getElementById("home-show-media-box-video").poster="./img/r6s-event-header-grandLarceny.jpg";
		document.getElementById("home-show-media-box-video").src = "./img/r6s-event-header-grandLarceny.mp4";
		
		document.getElementById("home-show-info-1").innerHTML="The Grand Larceny";
		document.getElementById("home-show-info-2").innerHTML="激战风云";
    }

    document.getElementById("checkpoint-3").onmouseover = function () 
	{
		clearAllCheckpoint();
		document.getElementById("checkpoint-3").style.backgroundColor="#ffffff";
		
		document.getElementById("home-show-media-address").href="https://www.ubisoft.com/en-us/game/rainbow-six/siege/game-info/seasons/voidedge";
		document.getElementById("home-show-info-address").href="https://www.ubisoft.com/en-us/game/rainbow-six/siege/game-info/seasons/voidedge";
		
		document.getElementById("home-show-media-box-img").alt="OPERATION VOID EDGE";
		document.getElementById("home-show-media-box-img").src = "./img/VoidEdge.jpg";
		
		document.getElementById("home-show-media-box-video").alt="OPERATION VOID EDGE";
		document.getElementById("home-show-media-box-video").poster="./img/VoidEdge.jpg";
		document.getElementById("home-show-media-box-video").src = "./img/r6s-header-patchnotes-void-edge.mp4";
		
		document.getElementById("home-show-info-1").innerHTML="VOID EDGE";		document.getElementById("home-show-info-2").innerHTML="虚空边缘";
    }
    
    document.getElementById("checkpoint-4").onmouseover = function () 
	{
		clearAllCheckpoint();
		document.getElementById("checkpoint-4").style.backgroundColor="#ffffff";
		
		document.getElementById("home-show-media-address").href="https://www.ubisoft.com/en-us/game/rainbow-six/siege/news-updates/3z2FXeE1xUJlsBxQTIrzBg/announcing-the-rainbow-6-north-american-league";
		document.getElementById("home-show-info-address").href="https://www.ubisoft.com/en-us/game/rainbow-six/siege/news-updates/3z2FXeE1xUJlsBxQTIrzBg/announcing-the-rainbow-6-north-american-league";
		
		document.getElementById("home-show-media-box-img").alt="ANNOUNCING THE RAINBOW 6 NORTH AMERICAN LEAGUE";
		document.getElementById("home-show-media-box-img").src = "./img/R6_NAL_GFX_KEYART_NAL_V2.jpg";
		
		document.getElementById("home-show-media-box-video").alt="";
		document.getElementById("home-show-media-box-video").poster="";
		document.getElementById("home-show-media-box-video").src ="";
		
		document.getElementById("home-show-info-1").innerHTML="NORTH AMERICAN LEAGUE";
		document.getElementById("home-show-info-2").innerHTML="北美联盟";
    }
    

	
	//挑战信息
	document.getElementById("challenge-item-iconbox-1").onmouseover = function () 
	{
		clearAllInfo();
	    document.getElementById("challenge-item-info-1").style.opacity="1";	
		document.getElementById("challenge-item-iconbox-1").style.backgroundColor="#3f3f3f";
	}
	document.getElementById("challenge-item-iconbox-2").onmouseover = function ()
	{
		clearAllInfo();
		document.getElementById("challenge-item-info-2").style.opacity="1";
		document.getElementById("challenge-item-iconbox-2").style.backgroundColor="#3f3f3f";
	}
	document.getElementById("challenge-item-iconbox-3").onmouseover = function ()
	{
		clearAllInfo();
		document.getElementById("challenge-item-info-3").style.opacity="1";
		document.getElementById("challenge-item-iconbox-3").style.backgroundColor="#3f3f3f";
	}
	document.getElementById("challenge-item-iconbox-4").onmouseover = function ()
	{
		clearAllInfo();
		document.getElementById("challenge-item-info-4").style.opacity="1";
		document.getElementById("challenge-item-iconbox-4").style.backgroundColor="#3f3f3f";
	}
	document.getElementById("challenge-item-iconbox-5").onmouseover = function ()
	{
		clearAllInfo();
		document.getElementById("challenge-item-info-5").style.opacity="1";
		document.getElementById("challenge-item-iconbox-5").style.backgroundColor="#3f3f3f";
	}


	var c=document.getElementById('mycanvas');
	var ctx=c.getContext('2d');
	ctx.font='bold 16px Helvetica';		
	ctx.fillText('R6病友会',16,20);

}

//时间函数
function showtime() 
{
    var oDt = new Date();
    var iTimerid;
    var sTime = "";
    if (oDt.getHours() < 10) 
	{
        sTime += "0" + oDt.getHours() + ":";
    }
    else 
	{
        sTime += oDt.getHours() + ":";
    }
    if (oDt.getMinutes() < 10) 
	{
        sTime += "0" + oDt.getMinutes() + ":";
    }
    else 
	{
        sTime += oDt.getMinutes() + ":";
    }
    if (oDt.getSeconds() < 10) 
	{
        sTime += "0" + oDt.getSeconds();
    }
    else 
	{
        sTime += oDt.getSeconds();
    }
    document.getElementById("displaytime").innerHTML = "<span>" + sTime + "</span>";
}


function clearAllCheckpoint()
{
	var list=document.getElementsByClassName("checkpoint");
	for(var i=0;i<=3;i++)
	{
		list[i].style.backgroundColor="#2a2a2a";
	}
}

function clearAllInfo()
{
	var list=document.getElementsByClassName("challenge-item-iconbox");
	for(var i=0;i<=4;i++)
	{
		list[i].style.backgroundColor="#121212";
	}
	list=document.getElementsByClassName("challenge-item-info");
	for(var i=0;i<=4;i++)
	{
		list[i].style.opacity="0";
	}
}